<?php

/**
 * sfGuardUserProfile filter form base class.
 *
 * @package    edmuch
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasesfGuardUserProfileFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'user_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('user'), 'add_empty' => true)),
      'email'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'first_name'    => new sfWidgetFormFilterInput(),
      'last_name'     => new sfWidgetFormFilterInput(),
      'birthday'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'birth_year'    => new sfWidgetFormFilterInput(),
      'is_super_user' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'sex'           => new sfWidgetFormFilterInput(),
      'location'      => new sfWidgetFormFilterInput(),
      'picture'       => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'user_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('user'), 'column' => 'id')),
      'email'         => new sfValidatorPass(array('required' => false)),
      'first_name'    => new sfValidatorPass(array('required' => false)),
      'last_name'     => new sfValidatorPass(array('required' => false)),
      'birthday'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'birth_year'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'is_super_user' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'sex'           => new sfValidatorPass(array('required' => false)),
      'location'      => new sfValidatorPass(array('required' => false)),
      'picture'       => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('sf_guard_user_profile_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'sfGuardUserProfile';
  }

  public function getFields()
  {
    return array(
      'id'            => 'Number',
      'user_id'       => 'ForeignKey',
      'email'         => 'Text',
      'first_name'    => 'Text',
      'last_name'     => 'Text',
      'birthday'      => 'Date',
      'birth_year'    => 'Number',
      'is_super_user' => 'Boolean',
      'sex'           => 'Text',
      'location'      => 'Text',
      'picture'       => 'Text',
    );
  }
}
